const login = require('./common/script/login.js');
App({
  onLaunch(options) {
    // 第一次打开
    const that = this;
    //检测登陆
    login.checkLogin().then(res => {
      const openId = my.getStorageSync({
        key: 'openId'
      }).data;

      if (!openId) {
        login.loginByWeixin().then(res => {
          if (that.appCallBack) {
            that.appCallBack(true)
          }
        })
      }
    }).catch(err => {
      login.loginByWeixin().then(res => {
        if (that.appCallBack) {
          that.appCallBack(true)
        }
      })
    })
  },
  userLogin() {
    const that = this;
    login.loginByWeixin().then(res => {
      if (that.appCallBack) {
        that.appCallBack(true)
      }
    })
  },
  onShow(options) {
    // 从后台被 scheme 重新打开
    // options.query == {number:1}
  },

  
});